package othello.shared.model;

import java.io.Serializable;

import org.slim3.datastore.Attribute;
import org.slim3.datastore.Model;


import com.google.appengine.api.datastore.Key;

@Model(schemaVersion = 2)
public class StateAtLounge implements Serializable {

	private static final long serialVersionUID = 1L;

	@Attribute(primaryKey = true)
	private Key key;

	@Attribute(version = true)
	private Long version;

	/**
	 * セッションID
	 */
	private String sessionId;

	/**
	 * 対戦相手のセッション
	 */
	private String partnerId;

	/**
	 * マッチングした場合のゲームボードのID
	 */
	private String gameBoardId;

	/**
	 * ゲーム盤の駒色
	 */
	private GameStep.Side side;

	/**
	 * デフォルト・コンストラクター
	 */
	public StateAtLounge() {
	}

	/**
	 * Returns the key.
	 * 
	 * @return the key
	 */
	public Key getKey() {
		return key;
	}

	/**
	 * Sets the key.
	 * 
	 * @param key
	 *            the key
	 */
	public void setKey(Key key) {
		this.key = key;
	}

	/**
	 * Returns the version.
	 * 
	 * @return the version
	 */
	public Long getVersion() {
		return version;
	}

	/**
	 * Sets the version.
	 * 
	 * @param version
	 *            the version
	 */
	public void setVersion(Long version) {
		this.version = version;
	}

	public String getSessionId() {
		return sessionId;
	}

	public void setSessionId(String sessionId) {
		this.sessionId = sessionId;
	}

	public String getPartnerId() {
		return partnerId;
	}

	public void setPartnerId(String partnerId) {
		this.partnerId = partnerId;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((key == null) ? 0 : key.hashCode());
		return result;
	}

	public void setGameBoardId(String gameBoardId) {
		this.gameBoardId = gameBoardId;
	}

	public String getGameBoardId() {
		return gameBoardId;
	}

	public void setSide(GameStep.Side side) {
		this.side = side;
	}

	public GameStep.Side getSide() {
		return side;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		StateAtLounge other = (StateAtLounge) obj;
		if (key == null) {
			if (other.key != null) {
				return false;
			}
		} else if (!key.equals(other.key)) {
			return false;
		}
		return true;
	}

}
